import socket

# User inputs the message to be sent
message = input("Please enter the message to send: ")

# Target server's IPv4 address and port number
target_ipv4 = input("Please enter the target server's IPv4 address: ")
target_port = int(input("Please enter the target server's port number: "))

# Create a socket connection
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# Connect to the target server
client_socket.connect((target_ipv4, target_port))

# Set the number of times to repeat sending
repeat_times = int(input("Please enter the number of times to repeat sending: "))

# Loop to send the message to the target server
for i in range(repeat_times):
    client_socket.send(message.encode())
    print("Sent", i+1, "time(s)")

# Close the socket connection
client_socket.close()
